<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    
    <h:form id="frmLastName">
            <p:growl id="messageGeneral" showDetail="true" sticky="false" />
            
            <p:dataTable id="tabListLastName" var="itemLastName" 
                         value="#{mbVLastName.all}" paginator="true" rows="10" 
                         paginatorPosition="bottom"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} 
                                            {PreviousPageLink} {PageLinks} 
                                            {NextPageLink} {LastPageLink}"
                         emptyMessage="Нет фамилий"
                         filteredValue="#{mbVLastName.listLastNameFiltered}">
                
                <f:facet name="header">
                    Фамилии                            
                </f:facet>           
                <p:column width="100" headerText="Фамилия" filterBy="name">
                    <h:outputText value="#{itemLastName.name}"/>
                </p:column>
                <p:column width="100">
                    <p:commandButton icon="ui-icon-disk" 
                                     action="#{mbVLastName.setLastNameParent()}"
                                     oncomplete="dialogLastName.hide()"
                                     style="float:right;width:32px;height:32px;">
                        <f:setPropertyActionListener value="#{itemLastName}"
                                                     target="#{mbVLastName.lastName}" />
                    </p:commandButton>
                    <p:commandButton icon="ui-icon-trash"
                                     oncomplete="deleteLastNameDlg.show()"
                                     style="float:right;width:32px;height:32px;">
                    <f:setPropertyActionListener value="#{itemLastName}"
                                                 target="#{mbVLastName.lastName}" />
                    </p:commandButton>
                    <p:commandButton update=":frmLastName:editLastNameDialog" 
                                     icon="ui-icon-pencil"
                                     oncomplete="editLastNameDlg.show()"
                                     style="float:right;width:32px;height:32px;">
                        <f:setPropertyActionListener value="#{itemLastName}"
                                                     target="#{mbVLastName.lastName}" />
                    </p:commandButton>                
                </p:column>
            </p:dataTable>
            <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Новое имя" 
                                 oncomplete="newLastNameDlg.show()" />
            </h:panelGroup>
            
            <!-- Add new LastName -dialog -->
            <p:dialog widgetVar="newLastNameDlg" id="newLastNameDialog"
                      header="Новая фамилия" hideEffect="fade" 
                      showEffect="fade" resizable="false" closable="true">
                <p:outputLabel value="Фамилия" for="txtLastName"/>
                <p:inputText id="txtLastName" label="Фамилия" size="50" 
                             value="#{mbVLastName.newName}">
                </p:inputText>
                <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Сохранить" action="#{mbVLastName.registration()}"
                                 oncomplete="newLastNameDlg.hide();" update="tabListLastName">
                </p:commandButton>
                <p:commandButton value="Отменить" oncomplete="newLastNameDlg.hide();"
                                 action="#{mbVLastName.cancel()}" />
                </h:panelGroup>
            </p:dialog>
            
            <!-- Delete LastName -dialog -->
            <p:dialog widgetVar="deleteLastNameDlg" id="deleteLastNameDialog"
                      header="Удаление фамилии" hideEffect="fade"
                      showEffect="fade" resizable="false" 
                      closable="true">
                <h:outputText value="Удаляем фамилию?" />
                <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Удалить" action="#{mbVLastName.remove()}"
                                 oncomplete="deleteLastNameDlg.hide();" update="tabListLastName">
                </p:commandButton>
                <p:commandButton value="Отменить"
                                 oncomplete="deleteLastNameDlg.hide();"
                                 action="#{mbVLastName.cancel()}" />
                </h:panelGroup>
            </p:dialog>
            
            <!-- Editing LastName -dialog -->
            <p:dialog widgetVar="editLastNameDlg" id="editLastNameDialog"
                      header="Редактирование фамилии" hideEffect="fade"
                      showEffect="fade" resizable="false" closable="true">
                <p:outputLabel value="Фамилия" for="txtLastNameUpdate"/>
                <p:inputText id="txtLastNameUpdate" label="Фамилия" size="50" 
                             value="#{mbVLastName.lastName.name}"/>
                <h:panelGroup layout="block" style="text-align: right">
                <p:commandButton value="Сохранить" action="#{mbVLastName.update()}"
                                 oncomplete="editLastNameDlg.hide();" update="tabListLastName">
                </p:commandButton>
                <p:commandButton value="Отменить" oncomplete="editLastNameDlg.hide();"
                                 action="#{mbVLastName.cancel()}" />
                </h:panelGroup>
            </p:dialog>
            
                           
        </h:form> 
</html>

